home *** CD-ROM | disk | FTP | other *** search
/ Commodore Free 9 / Commodore_Free_Issue_09_2007_Commodore_Computer_Club.d64 / t.shredz64 2 < prev    next >
Text File  |  2023-02-26  |  11KB  |  347 lines

  1. u         The Shredz64 Project
  2.           By Toni Westbrook
  3. PART 2
  4.  
  5. After a hefty debugging session, the
  6. physical adapter is solid and works
  7. great with both a guitar controller
  8. and normal dual shock controller. It
  9. was amazing to try all my old games
  10. with a PS2 controller (as well as some
  11. Amiga games and Atari 2600, haven't
  12. tried the Sega Master System yet).
  13.  
  14. Also, I've started writing the actual
  15. Shredz64 (guitar hero) game for the
  16. C64. I started out with a simple
  17. debugging routine to show the status
  18. of what guitar buttons were being
  19. pressed. Here are two screenshots
  20. (literally) of the C64 reporting whats
  21. happening on both the fret board and
  22. strum bar/lift sensor:
  23.  
  24. While this program was written in
  25. BASIC, the final Shredz64 program is
  26. being written in a combination of C
  27. and 6502 assembly using the CC65 cross
  28. compiler, which I got up and running a
  29. few days ago. I'm currently developing
  30. in an emulator environment and am
  31. waiting for parts to arrive to build a
  32. cable to transfer the program to the
  33. C64 itself for testing.
  34.  
  35. Anyway, so much more to come, but
  36. things are progressing nicely! I've
  37. found out that this project is
  38. featured in Engadget which is great, I
  39. hope to be making updates more
  40. regularly now that I know people are
  41. reading. If you have any questions,
  42. feel free to email me: twestbrook AT
  43. synthdreams DOT com. Huzzah!
  44.  
  45. 1/10/07 - 1/11/07 I recently ordered
  46. the arduino development board - it's a
  47. programming board for the ATMEGA8
  48. microcontroller with a built in USB
  49. interface. It was extremely cheap 35
  50. for the board, 3 bucks per ATMega8
  51. chip). The IDE allows you to program
  52. in C code and upload it straight to
  53. the flash memory on the ATMega, which
  54. is called by the bootloader on
  55. startup. The ATMega8 is awesome for 3
  56. bucks, it runs at 16mhz, has 1K RAM,
  57. 8K flash memory, and 512 bytes of
  58. EEPROM memory. Great for a project
  59. like this. HOW DOES THIS RELATE TO THE
  60. GUITAR HERO CONTROLLER?
  61.  
  62. Well, long gone are the days when a
  63. joystick simply put voltage over a
  64. line to indicate a button being
  65. pressed. This is true on
  66. Atari/Commodore/Sega/Amiga
  67. controllers, but nothing recent. Back
  68. in the day, if you pressed LEFT, a
  69. circuit to a specific pin would be
  70. completed on the 9 pin connector.
  71. Press up, a different pin would be
  72. connected. A pin for every button, it
  73. was an easy life. But now PSX, XBOX,
  74. GC controllers have a billion buttons
  75. and only a limited number of lines, so
  76. they encode the data into a serial
  77. stream of packets, just like if you
  78. were sending data over a serial
  79. connection or network. In comes the
  80. ATMega8 microcontroller. The atmega
  81. receives the serial stream of packets,
  82. decodes them and figures out which
  83. buttons are being pressed. It then
  84. drops voltage on corresponding lines
  85. to the output to the commodore. But
  86. before I did that I had to test to
  87. make sure my decoding program was
  88. working! THIS WAS A NEAT TEST.
  89.  
  90. First I took a PSX extender cable: I
  91. opened the male connector and got the
  92. pins out. I continuity tested each
  93. line so I could figure out which color
  94. was which pin. I then connected these
  95. pins into a solderless protoboard and
  96. mapped arbitrary pins off the arduino
  97. board into the protoboard. I also
  98. hooked a tiny loudspeaker up to the
  99. protoboard too and mapped the arduino
  100. into it. The goal to test this guy out
  101. was to have the ATMega play sounds on
  102. the speaker when I strummed with
  103. buttons held down on the guitar.
  104.  
  105. Then was the task of writing the
  106. decoder in C. I found some docs online
  107. that describe the protocol the PSX
  108. controller uses. It basically consists
  109. of sending data over a COMMAND line,
  110. listening on the DATA line,
  111. manipulating the CLOCK line to drive
  112. the data, checking the ACK line for
  113. good measure (not really necessary),
  114. and dropping the ATTENTION line when
  115. it was time to wake the controller up.
  116. The prototal was the following. Drop
  117. the attention line, Send 0x01 over the
  118. COMMAND line to the controller, the
  119. arduino should receive 0xFF back on
  120. the data line. Then the controller is
  121. sent 0x42 which is a REQUEST FOR DATA
  122. command, at the same time the
  123. controller responds back with what
  124. mode it is in (Digital or Analog,
  125. mouse or whatever). It then sends back
  126. 0x5A to indicate "Here comes the data
  127. SUCKA", and then sends 2-7 bytes
  128. depending on if the controller is in
  129. digital or analog mode. Those bytes
  130. contain a bit for each button, either
  131. set to 0 or 1 depending on if the
  132. button is pressed or not.
  133.  
  134. It took about two days to get this
  135. working, one because I needed to add a
  136. 10K pullup resistor across the COMMAND
  137. pin as the arduino was polling the
  138. controller too fast and the line noise
  139. was crapping out any packets I was
  140. sending. I found this tip online by
  141. someone who had done another PSX
  142. controller project. The other was I
  143. wasn't reading and writing data
  144. properly with the clock cycle, I was
  145. doing more on the rise of the clock
  146. and I needed to do things on the fall
  147. of the clock. It was frustrating, but
  148. eventually I got it working. I then
  149. wrote a quick program to print out to
  150. my laptop (via the USB serial link)
  151. what button was being pressed, then I
  152. pressed each button on the guitar
  153. controller and saw what the
  154. corresponding PSX button was. Here's
  155. THAT:
  156.  
  157. Green = R2
  158. Red = O
  159. Yellow = Triangle
  160. Blue = X
  161. Orange = Square
  162. Start = Start
  163. Select = Select Lift
  164. guitar up = L2 Strum
  165. up = UP Strum
  166. down = DOWN
  167.  
  168. I couldn't test the whammy bar out as
  169. I know for a fact it manipulates one
  170. of the analog sticks, and I don't know
  171. the command yet to force a controller
  172. into analog mode, so the guitar starts
  173. up in digital mode and disables the
  174. whammy bar.
  175.  
  176. Anyway, I got the decoder working, and
  177. using the button map data, I created a
  178. little program for the atmega that
  179. plays a note through the loudspeaker
  180. when the strum bar is hit depending on
  181. what key combination is held down
  182. during the strum. It basically assigns
  183. a frequency value to each key, then
  184. adds them together, and plays that.
  185. It's not aligned to real notes right
  186. now, I did it more for just a fun test
  187. to actually see the thing working.
  188. There really is no other steps between
  189. here and hooking it to the commodore
  190. 64 other than wiring up a DB9
  191. conector.
  192.  
  193. That's it for now! Soon the interface
  194. will be done and it will be time to
  195. start on the game.
  196.  
  197. The Interface The PSX64 interface
  198. connects playstation controllers to
  199. computers that use a DB9 port and C64
  200. pin configuration (such as the Amiga,
  201. Atari 2600, Sega Master System, etc).
  202. Additionally, if a guitar controller
  203. is detected, it will encode strum up,
  204. strum down, lift up, and the whammy
  205. bar onto the two potentiometer lines
  206. of the joystick port. While this extra
  207. guitar functionality is usable by the
  208. Shredz64 game only (and any future
  209. projects), the normal functionality of
  210. the PSX64 interface can be used with
  211. any game, and works well!
  212.  
  213. The PSX64 features the following:
  214.  
  215. 1. The aforementioned ability to hook
  216. a playstation controller up to a DB9
  217. joystick computer. It maps up, down,
  218. left, right and X on the PSX
  219. controller to up, down, left, right,
  220. and fire on the computer,
  221. respectively.
  222.  
  223. 2. If the playstation controller is
  224. put into analog mode, it will also map
  225. over the left analog control stick to
  226. the 4 up/down/left/right directions.
  227.  
  228. 3. On a normal playstation controller,
  229. if the start button is pressed, the
  230. PSX64 goes into programming mode. The
  231. user can then hit L1, L2, R1, or R2,
  232. and program up to 127 buttons in for a
  233. macro mapped to that button. Hitting
  234. start again ends programming mode and
  235. saves the macro. These macros are
  236. saved in the PSX64's EEPROM and will
  237. be retained after power off.
  238.  
  239. 4. If a guitar is plugged in, the
  240. PSX64 goes into guitar mode and maps
  241. the fretboard buttons into up, down,
  242. left, right, and fire. It encodes
  243. strum up, strum down, and lift up into
  244. one of the POT lines. It encodes the
  245. value of the whammy bar into the other
  246. POT line.
  247.  
  248. 5. The PSX64 uses a socket mounted
  249. ATMega8 microcontroller, flashable
  250. with firmware updates with easy to
  251. build programmers. It makes use of two
  252. digital potentiometers for accurate
  253. strum and whammy encoding. It does
  254. require a 9v-15v DC power supply to
  255. operate.
  256.  
  257. Shredz64 the game Shredz64 is (will be
  258. if successful!) a game for the
  259. Commodore 64 that makes use the
  260. playstation guitar controller hooked
  261. through the PSX64 interface. It is in
  262. the beginning stages right now, with
  263. only button testing and some graphics
  264. routines done, but is on a steady
  265. track. There is a good chance Shredz64
  266. will make use of SID and/or MID files
  267. for its music, though with channel
  268. constraints,
  269.  
  270. SID files are more likely than MIDI
  271. files off the bat. Some obstacles to
  272. be worked through include presentation
  273. of music given the 3 voice nature of
  274. the 6581 and 8580. Calculation,
  275. whether static or dynamic, of fret
  276. button mappings to notes as well.
  277. Also, efficiency needed for quick
  278. polling of the guitar controller.
  279.  
  280. I'm keeping the graphics very simple,
  281. confined to PETSCII and sprites during
  282. the early phases, since I want to save
  283. all the processing power I can for the
  284. music and response. If I have some
  285. extra cycles left over at the end,
  286. I'll tweak and polish up the graphics.
  287. Anyway, you can see the (very)
  288. beginnings of how the main screen will
  289. look.
  290.  
  291. Why do it Ha, this seems to be a
  292. question I get a lot. In December of
  293. 2006, I attended the TPUG World of
  294. Commodore convention in Toronto,
  295. Canada, and found hundreds of people
  296. still very much interested in the
  297. Commodore 64 and expanding its
  298. capabilities, even today. I saw some
  299. awesome demos of people building
  300. network adapters, online games, MIDI
  301. interfaces, and other cool stuff for
  302. their C64s.
  303.  
  304. I fell in love with the idea - I love
  305. the C64 and I love hacking around with
  306. software and hardware alike, so I
  307. figured this would be the perfect
  308. project! Around the same time I had
  309. also read about Jeri Ellsworth and her
  310. amazing work and success with
  311. recreating the C64, and I was just
  312. really inspired all around. If all
  313. goes well, perhaps I can present my
  314. little project at next years TPUG
  315. conference!
  316.  
  317. Really, when it comes right down to
  318. it, I work on "more serious" projects
  319. all the time, for my day job, for
  320. private contracts, all the time. They
  321. pay the bills, and I do enjoy them,
  322. but I also like to do fun, wacky
  323. stuff. We live in a world where a
  324. computer older than 6-7 is considered
  325. useless, let alone 25 years.  Well, I
  326. absolutely love my Commodore 64, it
  327. has a lot of meaning and memories for
  328. me, and I love doing fun things with
  329. it - and there's no reason why it
  330. can't do a lot of cool things, even
  331. still. You don't always need a piece
  332. of equipment that can perform 4
  333. billion calculations per second,
  334. sometimes 1 million is more than
  335. enough. Plus, come on, hooking a
  336. playstation guitar up to a Commodore
  337. 64 is just damn cool. ;)
  338.  
  339. For more information head over to the
  340. SHEDZ64 website
  341. http://freedomirc.net/{$fe}megaboz/shredz6
  342. 4/
  343.  
  344.  
  345. ...end...
  346. www.commodorefree.com
  347.  
  348.